package com.ibeetl.cms.service;

import java.util.List;

import com.ibeetl.cms.entity.DoctoralSubsidy;
import com.ibeetl.cms.entity.KeyInformation;
import com.ibeetl.cms.util.ProcessConstant;
import com.ibeetl.cms.web.query.OutboundSubsidyQuery;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ibeetl.admin.core.util.PlatformException;

import com.ibeetl.cms.dao.OutboundSubsidyDao;
import com.ibeetl.cms.entity.OutboundSubsidy;
import com.ibeetl.admin.core.service.BaseService;

/**
 * OutboundSubsidy Service
 */

@Service
@Transactional
public class OutboundSubsidyService extends BaseService<OutboundSubsidy>{

    @Autowired
    private OutboundSubsidyDao outboundSubsidyDao;

    public PageQuery<OutboundSubsidy>queryByCondition(PageQuery query){
        PageQuery ret =  outboundSubsidyDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelOutboundSubsidy(List<Long> ids){
        try {
            outboundSubsidyDao.batchDelOutboundSubsidyByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除OutboundSubsidy失败", e);
        }
    }

    public PageQuery<OutboundSubsidy> queryEmployees(PageQuery page) {
        page.setPageSize(Integer.MAX_VALUE);

        PageQuery ret =  outboundSubsidyDao.queryEmployees(page);
        queryListAfter(ret.getList());
        return ret;
    }

    //查企业
    public PageQuery<OutboundSubsidy>findenterprise(PageQuery query){
        PageQuery ret =  outboundSubsidyDao.findenterprise(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public List<OutboundSubsidy>queryCompany(OutboundSubsidyQuery condtion){
        List<OutboundSubsidy> ret =  outboundSubsidyDao.queryCompany(condtion);
        queryListAfter(ret);
        return ret;
    }
    public PageQuery<OutboundSubsidy> queryDoneTask(PageQuery page) {
        PageQuery ret =  outboundSubsidyDao.queryDoneTask(page);
        queryListAfter(ret.getList());
        return ret;

    }

    public int queryEmployeesCount(OutboundSubsidyQuery condition) {
        return outboundSubsidyDao.queryEmployeesCount(condition);
    }

    /**
     * 根据user_id查询已生效的出站人才业务数目
     * @param userId
     * @return
     */
    public  int finddoneStr(Long userId){
        return outboundSubsidyDao.finddoneStr(userId, ProcessConstant.DONE);
    }
}